- /* combUL.cpp by K.Tsuru */
- /**************************************
- It provides a binomial coefficient nCk
- ulong version. When n < 30 does not overflow.
- **************************************/
- #include "typedef.h"
-
- ulong combUL(ulong n, ulong k) {
- // k = min(n, n - k);
- if(n < k) return 0;
- k = (n < n - k) ? n : n-k; // if n==k, k becomes 0.
- ulong r;
- if(k == 0) r = 1; // includes the case n == k
- else {
- r = combUL(n-1, k-1);
- r *=n; r/= k;
- }
- return r;
- }
combUL.cpp : last modifiled at 2016/10/10 22:38:23(490 bytes)
created at 2016/10/29 15:19:49
The creation time of this html file is 2017/10/07 10:54:15 (Sat Oct 07 10:54:15 2017).